package org.dromara.tearoom.dubbo;

import cn.hutool.core.bean.BeanUtil;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.tearoom.api.RemotePayService;
import org.dromara.tearoom.api.domain.bo.RemoteHtlOrderBo;
import org.dromara.tearoom.api.domain.bo.RemotePayCommonBo;
import org.dromara.tearoom.api.domain.vo.RemotePayVo;
import org.dromara.tearoom.domain.TerOrder;
import org.dromara.tearoom.domain.bo.TerOrderBo;
import org.dromara.tearoom.domain.enums.OrderStatusContent;
import org.dromara.tearoom.domain.vo.WxSignParam;
import org.dromara.tearoom.service.ITerOrderService;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
@Service
@DubboService
public class RemotePayServiceImpl implements RemotePayService {
    private final ITerOrderService terOrderService;

    @Override
    public RemotePayVo pay(RemotePayCommonBo bo) {
        TerOrder order = BeanUtil.toBean(bo, TerOrder.class);
        WxSignParam wsp= terOrderService.commonPay(order);
        return BeanUtil.toBean(wsp, RemotePayVo.class);
    }


    @Override
    public String refund(RemoteHtlOrderBo bo){
        return terOrderService.getRefundId(BeanUtil.toBean(bo, TerOrderBo.class));
    }
}
